package com.example.Dao;

import com.example.pojo.Article;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ArticleMapper {

    //2.添加文章
    @Insert("insert into article(title,content,coverImg,state,categoryId,createUser" +
            ",createTime,updateTime) values (#{title},#{content},#{coverImg},#{state}," +
            "#{categoryId},#{createUser},#{createTime},#{updateTime})")
    void add(Article article);

    //3.删除文章
    @Delete("delete from article where id = #{id}")
    void deleteArticle(Integer id);

    //4.1查询总记录数
    @Select("select count(*) from article;")
    Long total();

//    @Select("select * from article limit #{startIndex},#{pageSize}")
    //4.2条件查询
    List<Article> page(Integer startIndex, Integer pageSize, Integer categortId, String state, Integer createId);





}
